package com.entity;

public class Pagination {
	// 当前页数
	private int currentPage = 1;
	// 每页显示数量
	private int everyPage = 20;
	// 总页数
	private int totalPage;
	// 总数量
	private int totalCount;
	private int startRow = 0;
	private int endRow = startRow + everyPage;

	public Pagination() {
	}

	// 可以将dwz传过来的pageNum、numPerPage进行初始化
	public Pagination(int pageNum, int numPerPage) {
		this.currentPage = pageNum;
		this.everyPage = numPerPage;
	}

	public int getTotalPage() {
		return totalPage;
	}

	@Override
	public String toString() {
		return "Pagination [currentPage=" + currentPage + ", everyPage="
				+ everyPage + ", totalPage=" + totalPage + ", totalCount="
				+ totalCount + ", startRow=" + startRow + ", endRow=" + endRow
				+ "]";
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	// 设置总数量的同时，设置总页数
	public void setCount(int totalCount) {
		this.totalCount = totalCount;
		int temp = 0;
		if (totalCount % this.everyPage != 0) {
			temp++;
		}
		this.totalPage = totalCount / this.everyPage + temp;
		startRow = (currentPage - 1) * everyPage;
		endRow = startRow + everyPage;
	}

	public int getStartRow() {
		return startRow;
	}

	public void setStartRow(int startRow) {
		this.startRow = startRow;
	}

	public int getEndRow() {
		return endRow;
	}

	public void setEndRow(int endRow) {
		this.endRow = endRow;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public int getEveryPage() {
		return everyPage;
	}

	public int getTotalCount() {
		return totalCount;
	}

}
